* Perspectives on Politics
* Government Targeting of Refugees in the Midst of Epidemics
* by Alex Braithwaite, Michael Frith, Burcu Savun, and Faten Ghosn 

use "Braithwaiteetal.dta"


* Table 1: 
summarize govagainstref eps_bin_ctry_lag1yr eps_num_ctry_lag1yr epdeaths_ctry_ln_lag1yr epaffected_ctry_ln_lag1yr refpop_perc_lag1yr refpopexcluded_ln_lag1yr polterror_lag1yr democracy_lag1yr statestrength_lag1yr gdppc_ln_lag1yr civilconflict_lag1yr


* Table 2: 
tab  eps_bin_ctry_lag1yr govagainstref_lag1yr, row chi
* tab  eps_num_ctry_lag1yr govagainstref_lag1yr, row chi


* Table 3:
* Model 1: Pooled effects
ologit govagainstref eps_bin_ctry_lag1yr refpop_perc_lag1yr refpopexcluded_ln_lag1yr polterror_lag1yr democracy_lag1yr statestrength_lag1yr gdppc_ln_lag1yr civilconflict_lag1yr, cluster(country_iso)
* Model 2: lagged DV
ologit govagainstref eps_bin_ctry_lag1yr  refpop_perc_lag1yr refpopexcluded_ln_lag1yr polterror_lag1yr democracy_lag1yr statestrength_lag1yr gdppc_ln_lag1yr civilconflict_lag1yr govagainstref_lag1yr, cluster(country_iso)
* Model 3: Fixed Effects
feologit govagainstref eps_bin_ctry_lag1yr refpop_perc_lag1yr refpopexcluded_ln_lag1yr polterror_lag1yr democracy_lag1yr statestrength_lag1yr gdppc_ln_lag1yr civilconflict_lag1yr, group(country_iso)


* Table 4: 
* Model 4 - presence over 3 years
ologit govagainstref eps_bin_ctry_prev3yr refpop_perc_lag1yr refpopexcluded_ln_lag1yr polterror_lag1yr democracy_lag1yr statestrength_lag1yr gdppc_ln_lag1yr civilconflict_lag1yr, cluster(country_iso)
* Model 5 - truncated count
ologit govagainstref eps_truncnum_ctry_lag1yr refpop_perc_lag1yr refpopexcluded_ln_lag1yr polterror_lag1yr democracy_lag1yr statestrength_lag1yr gdppc_ln_lag1yr civilconflict_lag1yr, cluster(country_iso)
* Model 6 - deaths
ologit  govagainstref epdeaths_ctry_ln_lag1yr refpop_perc_lag1yr refpopexcluded_ln_lag1yr polterror_lag1yr democracy_lag1yr statestrength_lag1yr gdppc_ln_lag1yr civilconflict_lag1yr, cluster(country_iso)
* Model 7 - affected
ologit  govagainstref epaffected_ctry_ln_lag1yr refpop_perc_lag1yr refpopexcluded_ln_lag1yr polterror_lag1yr democracy_lag1yr statestrength_lag1yr gdppc_ln_lag1yr civilconflict_lag1yr, cluster(country_iso)


* Table 5
* Model 8: ref pop share interaction
ologit govagainstref eps_bin_ctry_lag1yr##c.refpop_perc_lag1yr refpopexcluded_ln_lag1yr polterror_lag1yr democracy_lag1yr statestrength_lag1yr gdppc_ln_lag1yr civilconflict_lag1yr, cluster(country_iso)
* Model 9: democracy interaction
ologit govagainstref eps_bin_ctry_lag1yr##c.democracy_lag1yr refpop_perc_lag1yr refpopexcluded_ln_lag1yr polterror_lag1yr statestrength_lag1yr gdppc_ln_lag1yr civilconflict_lag1yr, cluster(country_iso)


* For the folowing graphs, download "cleanplots" package first:
* net install cleanplots, from("https://tdmize.github.io/data/cleanplots")
* set scheme cleanplots, perm
* Stata's default graphic scheme is s2color. To change back to the default:set scheme s2color, perm

* Figure 1: Marginal Effect of Epidemics on Refugee Violence conditional refugee population size 
ologit govagainstref eps_bin_ctry_lag1yr##c.refpop_perc_lag1yr refpopexcluded_ln_lag1yr polterror_lag1yr democracy_lag1yr statestrength_lag1yr gdppc_ln_lag1yr civilconflict_lag1yr, cluster(country_iso)
margins , dydx(eps_bin_ctry_lag1yr)  at( refpop_perc_lag1yr=(0(0.5)7.7)) expression(predict(pr outcome(1))+predict(pr outcome(2))) vsquish 
marginsplot, recast(line) recastci(rarea) ciop(col(gs11))  xtitle("Refugee population share", size(small)) xlabel(0 "0" 2.5 "2.5" 5 "5" 7.5 "7.5", labsize(2.5)) graphregion (color(white)) plotregion(margin(none)) title("") ytitle("Marginal Effect", size(small)) ylab(0 "0" 0.2 "20" .4 "40" .6 "60" .8 "80" 1 "100", labsize(2.5))  plotopts(lcolor(red) mcolor(black)) title("Average Marginal Effect of Epidemics across Refugee Population",size(medium)) yline(0)


* Figure 2: Marginal Effect of Epidemics on Refugee Violence conditional regime type
ologit govagainstref eps_bin_ctry_lag1yr##c.democracy_lag1yr refpop_perc_lag1yr refpopexcluded_ln_lag1yr polterror_lag1yr statestrength_lag1yr gdppc_ln_lag1yr civilconflict_lag1yr, cluster(country_iso)
margins , dydx(eps_bin_ctry_lag1yr)  at( democracy_lag1yr=(0(1)9)) expression(predict(pr outcome(1))+predict(pr outcome(2))) vsquish
marginsplot, recast(line) recastci(rarea) ciop(col(gs11))  xtitle("Regime Type", size(small)) xlabel(0 "Closed autocracy" 1 " " 2 " " 3 "Electoral autocracy" 4 " " 5 " " 6 "Electoral democracy" 7 " " 8 " " 9 "Liberal democracy", angle(vertical) labsize(2.5)) graphregion (color(white)) plotregion(margin(none)) title("") ytitle("Marginal Effect", size(small)) ylab(-0.10 "-10" -0.05 "-5" 0"0" 0.05 "5" .10 "10" .15 "15" .20 "20"  .25 "25" , labsize(2.5))  plotopts(lcolor(red) mcolor(black)) title("Average Marginal Effect of Epidemics across Regime Type",size(medium)) yline(0)
